package com.lifeonwalden.dsg.constant;

import java.util.HashMap;
import java.util.Map;

public enum Frequency {
    NIL(0), DAY(4), WEEK(5), MONTH(1), QUARTER(2), YEAR(3);

    private static final Map<Integer, Frequency> valueMapping = new HashMap<Integer, Frequency>();
    private int value;

    Frequency(int value) {
        this.value = value;
    }

    static {
        Frequency[] enumArray = Frequency.values();
        for (Frequency enumItem : enumArray) {
            valueMapping.put(enumItem.getValue(), enumItem);
        }
    }

    public int getValue() {
        return value;
    }

    public static Frequency valueOf(int value) {
        Frequency enumItem = valueMapping.get(value);
        return null == enumItem ? NIL : enumItem;
    }
}